import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myflutterproject/basematerialwidgetsdemo.dart';

class IgnorePointerDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState()=>IgnorePointerState();
}
class IgnorePointerState extends State<IgnorePointerDemo>{
  String text='';
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('IgnorePointer'),
          centerTitle: true,
        ),
        body: Center(
          child: Container(
            child: Stack(
              alignment: Alignment.center,
              children: <Widget>[
                Container(
                  width: 200,
                  height: 200,
                  child: RaisedButton(
                      color: Colors.red,
                      onPressed: () {
                        print("click red");
                        setState(() {
                          text='click red';
                        });
                      }),
                ),
                IgnorePointer(
                  //忽略点击事件，不影响下层的点击事件
//            AbsorbPointer( //消费掉点击事件，下层也收不到，不会做出相应
                  child: Container(
                    width: 100,
                    height: 100,
                    child: RaisedButton(
                      color: Colors.blue,
                      onPressed: () {
                        print("click blue");
                        setState(() {
                          text='click blue';
                        });
                      },
                    ),
                  ),
                ),
                TextWidget(text),
              ],
            ),
          ),
        ));
  }
}
